﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.SlotJoint.CApPointManipulator
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System.Collections;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.SlotJoint;

internal class CApPointManipulator
{
  private TxManipulator _manipulator;
  private TxColor _manipulatorColor;

  public CApPointManipulator(
    TxTransformation pickedLocationTransformation,
    TxTransformation projectedLocationTransformation,
    TxColor color)
  {
    this._manipulatorColor = color;
    this.CreateManipulator(pickedLocationTransformation, projectedLocationTransformation);
  }

  private void CreateManipulator(
    TxTransformation pickedLocationTransformation,
    TxTransformation projectedLocationTransformation)
  {
    TxManipulatorSymbolElementData manipulatorPlusElement1 = TxManipulatorEx.CreateManipulatorPlusElement(pickedLocationTransformation);
    ((TxManipulatorElementData) manipulatorPlusElement1).AlwaysOnTop = false;
    ((TxManipulatorElementData) manipulatorPlusElement1).Color = this._manipulatorColor;
    TxManipulatorCreationData manipulatorCreationData = new TxManipulatorCreationData();
    ((TxObjectCreationData) manipulatorCreationData).Name = "SlotJointManipulator";
    ((TxLocatableObjectCreationData) manipulatorCreationData).AbsoluteLocation = pickedLocationTransformation;
    manipulatorCreationData.InsertElementData((TxManipulatorElementData) manipulatorPlusElement1);
    if (TxTransformation.op_Inequality(projectedLocationTransformation, (TxTransformation) null))
    {
      TxManipulatorSymbolElementData manipulatorPlusElement2 = TxManipulatorEx.CreateManipulatorPlusElement(projectedLocationTransformation);
      ((TxManipulatorElementData) manipulatorPlusElement2).Color = this._manipulatorColor;
      ((TxManipulatorElementData) manipulatorPlusElement2).AlwaysOnTop = true;
      manipulatorCreationData.InsertElementData((TxManipulatorElementData) manipulatorPlusElement2);
      TxManipulatorPolylineElementData polylineElementData1 = new TxManipulatorPolylineElementData(new TxTransformation(), new ArrayList()
      {
        (object) pickedLocationTransformation.Translation,
        (object) projectedLocationTransformation.Translation
      });
      ((TxManipulatorElementData) polylineElementData1).Color = new TxColor(byte.MaxValue, byte.MaxValue, (byte) 0);
      polylineElementData1.LineWidth = 2.0;
      ((TxManipulatorElementData) polylineElementData1).Pickable = false;
      ((TxManipulatorElementData) polylineElementData1).AlwaysOnTop = false;
      ((TxManipulatorElementData) polylineElementData1).Unzoomable = false;
      ((TxManipulatorElementData) polylineElementData1).AntiAlias = true;
      ((TxManipulatorElementData) polylineElementData1).Visibility = (TxManipulatorElementData.TxManipulatorElementVisibility) 65280;
      TxManipulatorPolylineElementData polylineElementData2 = polylineElementData1;
      manipulatorCreationData.InsertElementData((TxManipulatorElementData) polylineElementData2);
    }
    this._manipulator = TxApplication.ActiveDocument.PhysicalRoot.CreateManipulator(manipulatorCreationData);
    this._manipulator.AbsoluteLocation = new TxTransformation();
    this._manipulator.Display();
  }

  public void ChangeManipulatorLocation(
    TxTransformation pickedLocationTransformation,
    TxTransformation projectedLocationTransformation)
  {
    this.DestroyManipulator();
    this.CreateManipulator(pickedLocationTransformation, projectedLocationTransformation);
  }

  public void DestroyManipulator()
  {
    if (!TxManipulator.op_Inequality(this._manipulator, (ITxObject) null))
      return;
    this._manipulator.Delete();
    this._manipulator = (TxManipulator) null;
  }
}
